package com.teaphy.coroutinecrawler.flow.operators.terminal

import kotlinx.coroutines.*
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.consume
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.produceIn


fun main() = runBlocking {
    val flow = flow<Int> {
        repeat(10) {
            delay(1000)
            emit(it)
        }
    }
    val produceIn = flow.produceIn(this)
    repeat(10) {
        delay(100)
        val receive = produceIn.receive()
        println("receive: $receive")
    }

    println("Done")
}